﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Text.RegularExpressions;
using NewsPub;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Response.Redirect("http://kueiwa.a118.72ym.cn");

    }
    public static string GetImgUrl(string HTMLStr)
    {
        string str = string.Empty;
        //string sPattern = @"^<img\s+[^>]*>";
        Regex r = new Regex(@"<img\s+[^>]*\s*src\s*=\s*([""]?)(?<url>\S+)\s*([""]?)*[""]", //注意这里的(?<url>\S+)是按正则表达式中的组来处理的，下面的代码中用使用到，也可以更改成其它的HTML标签，以同样的方法获得内容！
        RegexOptions.Compiled);
        Match m = r.Match(HTMLStr.ToLower());
        if (m.Success)
            str = m.Result("${url}");
        return str;
    }
    //返回多个路径的情况
    public static StringBuilder MyGetImgUrl(string text)
    {
        StringBuilder str = new StringBuilder();
        string pat = @"<img\s+[^>]*\s*src\s*=\s*([']?)(?<url>\S+)'?[^>]*>";

        Regex r
= new Regex(pat, RegexOptions.Compiled);

        Match m
= r.Match(text.ToLower());
        //int matchCount = 0;
        while (m.Success)
        {
            Group g = m.Groups[2];
            str.Append(g).Append(",");
            m = m.NextMatch();
        }
        return str;
    }
    protected void rptLink_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Repeater dlproduct = (Repeater)e.Item.FindControl("rptLink");
        //DataRowView rowv = (DataRowView)e.Item.DataItem;
        FriendLink rowv = (FriendLink)e.Item.DataItem;
        int CategoryId = Convert.ToInt32(rowv["ID"]);
        FriendLink classis = new FriendLink();
        dlproduct.DataSource = FriendLink.FindAllByID(CategoryId);
        dlproduct.DataBind();
        //DataProvider dp = new DataProvider();
        //string sql = "select * from news_category where upperid=" + CategoryId + " order by orderno";
        //dlproduct.DataSource = dp.GetTable(sql);
        //dlproduct.DataBind();
    }
}